﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebChamCong
{
    public partial class ActivePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private void MessageBox(string msg)
        {
            Label lbl = new Label();
            lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "')</script>";
            Page.Controls.Add(lbl);
        }
        protected void BtActive_Click(object sender, EventArgs e)
        {
            if (txtMa.Text != "" && Request.QueryString["active"] != null && BUS.AccountBUS.MaHoaMD5(txtMa.Text) == Request.QueryString["active"])
            {
                string mk = "Mật khẩu mới :" + BUS.AccountBUS.MaNgauNhien_SoChu(6);
                string md5pass = BUS.AccountBUS.MaHoaMD5(mk);
                if (BUS.AccountBUS.updateInfoAcc(Convert.ToInt32(Request.QueryString["id"]), md5pass))
                {
                    DTO.AccountDTO info = BUS.AccountBUS.getInfoByID(Convert.ToInt32(Request.QueryString["id"]));
                    MessageBox(BUS.EmailCalss.Send_Email(Properties.Settings.Default.Mail_Admin, info.Email, "Mật Khẩu Mới Của Bạn !", mk));
                }
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
    }
}